package com.jiangxiaofei.citycloud.httpUtil;

import com.jiangxiaofei.citycloud.bean.BaiduPlaceBean;
import com.jiangxiaofei.citycloud.bean.BannerBean;
import com.jiangxiaofei.citycloud.bean.DoWorkInfoBean;
import com.jiangxiaofei.citycloud.bean.FleaGoodBean;
import com.jiangxiaofei.citycloud.bean.FleaMenuBean;
import com.jiangxiaofei.citycloud.bean.FreshFruitCassifyBean;
import com.jiangxiaofei.citycloud.bean.FreshFruitHomeBean;
import com.jiangxiaofei.citycloud.bean.GoodDetailBean;
import com.jiangxiaofei.citycloud.bean.GoodIdBean;
import com.jiangxiaofei.citycloud.bean.GoodListBean;
import com.jiangxiaofei.citycloud.bean.JobBean;
import com.jiangxiaofei.citycloud.bean.JobListBean;
import com.jiangxiaofei.citycloud.bean.MapWorkBean;
import com.jiangxiaofei.citycloud.bean.MapWorkerBean;
import com.jiangxiaofei.citycloud.bean.NeedBean;
import com.jiangxiaofei.citycloud.bean.ParkBean;
import com.jiangxiaofei.citycloud.bean.ParkDetailInfoBean;
import com.jiangxiaofei.citycloud.bean.RealUserBean;
import com.jiangxiaofei.citycloud.bean.UserInfoBean;
import com.jiangxiaofei.citycloud.bean.VillageDetailBean;
import com.jiangxiaofei.citycloud.bean.VillageMenuBean;
import com.jiangxiaofei.citycloud.bean.VillageNewsBean;
import com.jiangxiaofei.citycloud.bean.WorkLabelBean;
import com.jiangxiaofei.citycloud.bean.WorkNumBean;

import java.util.List;

import retrofit2.http.Field;
import retrofit2.http.FormUrlEncoded;
import retrofit2.http.GET;
import retrofit2.http.POST;
import retrofit2.http.Query;
import rx.Observable;

/**
 * Created by 上官林超 on 2017/7/28.
 * todo 创建URL 连接
 */

public interface APIService {

    //获取美丽乡村菜单
/// @FormUrlEncoded
    @POST("Bcountry/category")
    Observable<HttpResult<List<VillageMenuBean>>> getVillageMenu();

    //获取乡村文章列表
    @GET("bcountry/articlelist")
    Observable<HttpResult<List<VillageNewsBean>>> getVillageList(@Query("page") String page,
                                                                 @Query("category") String category);

    //获取乡村文章详情
    @GET("bcountry/article")
    Observable<HttpResult<List<VillageDetailBean>>> getVillageDetail(@Query("id") int id);

    //发布新文章
    @FormUrlEncoded
    @POST("bcountry/addarticle")
    Observable<HttpResult<String>> addAddarticle(@Field("title") String tile,
                                                 @Field("content") String content,
                                                 @Field("author") int author,
                                                 @Field("category") int category,
                                                 @Field("img") String img,
                                                 @Field("localtion") String location);

    //修改文章
    @FormUrlEncoded
    @POST("bcountry/updatearticle")
    Observable<HttpResult<String>> updateAddarticle(@Field("title") String tile,
                                                    @Field("content") String content,
                                                    @Field("author") int author,
                                                    @Field("category") int category,
                                                    @Field("img") String img,
                                                    @Field("localtion") String location,
                                                    @Field("id") int id);


    //用户登陆
    @FormUrlEncoded
    @POST("employ/alluserlogin")
    Observable<HttpResult<List<UserInfoBean>>> getUser(@Field("name") String name,
                                                       @Field("password") String password);

    //获取用户ID
    @GET("employ/Alluserallrole")
    Observable<HttpResult<List<WorkLabelBean>>> getWorkLabel();

    //    发布求职信息
    @FormUrlEncoded
    @POST("employ/Addworkintro")
    Observable<HttpResult<String>> postDowork(@Field("userid") int id,
                                              @Field("introduce") String introduce,
                                              @Field("coverage") String coverage,
                                              @Field("lat") String lat,
                                              @Field("log") String log,
                                              @Field("role") String role,
                                              @Field("freetime") String freetime);

    //    查看找活详情
    @FormUrlEncoded
    @POST("employ/Getworkintro")
    Observable<HttpResult<List<DoWorkInfoBean>>> getDoWorkInfo(@Field("userid") int userId,
                                                               @Field("client") int client);

    //    添加实名认证
    @FormUrlEncoded
    @POST("employ/Addrealid")
    Observable<HttpResult<String>> addRealid(@Field("userid") int userId,
                                             @Field("sex") int sex,
                                             @Field("age") int age,
                                             @Field("place") String place,
                                             @Field("realname") String realName,
                                             @Field("idnumber") String idNumber);

    //添加招聘信息
    @FormUrlEncoded
    @POST("employ/Addjobs")
    Observable<HttpResult<String>> addJobs(@Field("userid") int userId,
                                           @Field("role") String role,
                                           @Field("workplace") String workspace,
                                           @Field("worktime") String workTime,
                                           @Field("other") String other,
                                           @Field("pay") int pay,
                                           @Field("phone") String phone,
                                           @Field("contacts") String contacts,
                                           @Field("lat") String lat,
                                           @Field("log") String log,
                                           @Field("description") String description);


    //    更新工作
    @FormUrlEncoded
    @POST("employ/updatejobs")
    Observable<HttpResult<String>> updateJobs(@Field("id") int id,
                                              @Field("userid") int userId,
                                              @Field("role") String role,
                                              @Field("workplace") String workspace,
                                              @Field("worktime") String workTime,
                                              @Field("other") String other,
                                              @Field("pay") int pay,
                                              @Field("phone") String phone,
                                              @Field("contacts") String contacts,
                                              @Field("lat") String lat,
                                              @Field("log") String log,
                                              @Field("description") String description);


    //获取全部已发布工作 列表信息
    @FormUrlEncoded
    @POST("employ/Getjobslist")
    Observable<HttpResult<List<JobListBean>>> getJobList(@Field("userid") int userId);


    //获取工作详细信息
    @FormUrlEncoded
    @POST("employ/Getjobs")
    Observable<HttpResult<List<JobBean>>> getJobInfo(@Field("id") int id,
                                                     @Field("client") int client);

    //    获取实名认证信息
    @FormUrlEncoded
    @POST("employ/Getrealid")
    Observable<HttpResult<List<RealUserBean>>> getRealUserInfo(@Field("userid") int userId);

    //获取附件劳务坐标
    @FormUrlEncoded
    @POST("employ/Getcatjob")
    Observable<HttpResult<List<MapWorkBean>>> getMapWork(@Field("role") int role);

    //    获取附件干活坐标
    @FormUrlEncoded
    @POST("employ/GetcatWorker")
    Observable<HttpResult<List<MapWorkerBean>>> getMapWorker(@Field("role") int role);

    //获取所有劳务
    @GET("employ/Getnearjob")
    Observable<HttpResult<List<MapWorkBean>>> getMapWorkAll();

    //获取所有干活
    @GET("employ/Getnearworker")
    Observable<HttpResult<List<MapWorkerBean>>> getMapWorkerAll();

    //    更新求职信息
    @FormUrlEncoded
    @POST("employ/updateworkintro")
    Observable<HttpResult<String>> updateWorkerInfo(@Field("userid") int id,
                                                    @Field("introduce") String introduce,
                                                    @Field("coverage") String coverage,
                                                    @Field("lat") String lat,
                                                    @Field("log") String log,
                                                    @Field("role") String role,
                                                    @Field("freetime") String freetime);

    //删除求职信息
    @GET("employ/deljob")
    Observable<HttpResult<String>> deleteWorkList(@Query("id") String id);

    //获取求职者数量
    @GET("employ/getallnum")
    Observable<HttpResult<List<WorkNumBean>>> getWorkerNum(@Query("client") int client);

    //获取工作数量
    @GET("employ/Getnumjobs")
    Observable<HttpResult<List<WorkNumBean>>> getWorkNum(@Query("client") int client);


    //获取百度place
    @GET("place/v2/search")
    Observable<BaiduPlaceBean> getBaiduPlace(@Query("q") String q,
                                             @Query("region") String region,
                                             @Query("output") String output,
                                             @Query("ak") String ak);

    //获取停车场数据
    @GET("park/parkingHomePage.do")
    Observable<ParkBean> getPark(@Query("lng") String lng,
                                 @Query("lat") String lat,
                                 @Query("city") String city,
                                 @Query("isReserve") int isReserve,
                                 @Query("displayType") int displayType,
                                 @Query("type") int type,
                                 @Query("pageSize") int pageSize,
                                 @Query("currentPage") int currentPage);

    //获取停车场详细信息
    @GET("park/getParkDetailsInfo.do")
    Observable<ParkDetailInfoBean> getParkInfo(@Query("parkSeq") String parkSeq);

    /**
     * 用户注册
     */
    @FormUrlEncoded
    @POST("Alluser/userregister")
    Observable<HttpResult<String>> userRegist(@Field("phonenum") String phoneNum,
                                              @Field("password") String passwork,
                                              @Field("code") int code,
                                              @Field("state") int state);

    /**
     * 检查手机号码是否重复
     */
    @FormUrlEncoded
    @POST("Alluser/checkphonenum")
    Observable<HttpResult<String>> isPhoneRepeat(@Field("phonenum") String phoneNum);

    /**
     * 用户登陆 （新）
     * todo 用户登陆修改完成后
     */
    @FormUrlEncoded
    @POST("Alluser/userlogin")
    Observable<HttpResult<List<UserInfoBean>>> userLogin(@Field("phonenum") String phoneNum,
                                                         @Field("password") String password);

    /**
     * 获取轮播图
     * 0  app进入页面banner
     * 1 - 8  八个模块进入页面banner
     * 9 -12 分别是二手市场四个分类进入的banner
     * 13为需求banner
     */
    @FormUrlEncoded
    @POST("comfun/getadimg")
    Observable<HttpResult<List<BannerBean>>> getBannerImg(@Field("id") int id);

    /**
     * 获取菜单主分类
     *
     * @param id
     * @return
     */
    @FormUrlEncoded
    @POST("sndmodule/Getsndcatf")
    Observable<HttpResult<List<FleaMenuBean>>> getFleaMainMenu(@Field("id") int id);

    /**
     * 获取菜单二级分类
     *
     * @param id
     * @return
     */
    @FormUrlEncoded
    @POST("sndmodule/Getsndcats")
    Observable<HttpResult<List<FleaMenuBean>>> getFleaSencendMenu(@Field("id") int id);

    /**
     * 获取菜单二级分类
     *
     * @param id
     * @return
     */
    @FormUrlEncoded
    @POST("sndmodule/Getsndcatt")
    Observable<HttpResult<List<FleaMenuBean>>> getFleaThreeMenu(@Field("id") int id);


    /**
     * 发布商品
     */
    @FormUrlEncoded
    @POST("sndmodule/addsndgoods")
    Observable<HttpResult<List<GoodIdBean>>> putFleaGoods(@Field("title") String title,
                                                          @Field("description") String descrption,
                                                          @Field("price") String price,
                                                          @Field("cat") int cat,
                                                          @Field("lat") String lat,
                                                          @Field("lng") String lng,
                                                          @Field("author") int author,
                                                          @Field("img") String img);

    /**
     * 拉取物资首页商品列表
     */
    @FormUrlEncoded
    @POST("sndmodule/Getsndnewgoods")
    Observable<HttpResult<List<FleaGoodBean>>> getHomeGoodList(@Field("page") int page);

    /**
     * 获取二手商品详细信息
     */
    @FormUrlEncoded
    @POST("sndmodule/Getsndgoods")
    Observable<HttpResult<List<GoodDetailBean>>> getGoodDetail(@Field("id") int id,
                                                               @Field("lng") String lng,
                                                               @Field("lat") String lat);

    /**
     * 获取子分类最新商品
     *
     * @param id
     * @param page
     * @return
     */
    @FormUrlEncoded
    @POST("sndmodule/Getsndonenewgoods")
    Observable<HttpResult<List<FleaGoodBean>>> getChildNewGoods(@Field("id") int id,
                                                                @Field("page") int page);


    /**
     * 获取商品排序列表
     *
     * @param id
     * @param page
     * @param lat
     * @param lng
     * @param issue
     * @param price
     * @param dis
     * @return
     */
    @FormUrlEncoded
    @POST("sndmodule/Getsndtwonewgoods")
    Observable<HttpResult<List<GoodListBean>>> getFleaGoodList(@Field("id") int id,
                                                               @Field("page") int page,
                                                               @Field("lat") String lat,
                                                               @Field("lng") String lng,
                                                               @Field("issue") String issue,
                                                               @Field("price") String price,
                                                               @Field("dis") String dis);

    /**
     * 发布物资需求
     */
    @FormUrlEncoded
    @POST("sndmodule/Addsndneeds")
    Observable<HttpResult<List<GoodIdBean>>> putFleaNeeds(@Field("title") String title,
                                                          @Field("description") String description,
                                                          @Field("lat") String lat,
                                                          @Field("lng") String lng,
                                                          @Field("price") String price,
                                                          @Field("cat") int cat,
                                                          @Field("author") int author);

    /**
     * 需求详情
     */
    @FormUrlEncoded
    @POST("sndmodule/Getsndneeds")
    Observable<HttpResult<List<NeedBean>>> getNeedDetail(@Field("id") int id,
                                                         @Field("lng") String lng,
                                                         @Field("lat") String lat);

    /**
     * 拉取需求列表  及排序
     */
    @FormUrlEncoded
    @POST("sndmodule/Getsndoneneeds")
    Observable<HttpResult<List<NeedBean>>> getNeedList(@Field("id") int id,
                                                       @Field("page") int page,
                                                       @Field("lat") String lat,
                                                       @Field("lng") String lng,
                                                       @Field("issue") int issue);

    /**
     * 商品搜素
     */
    @FormUrlEncoded
    @POST("sndmodule/Searchsndgoods")
    Observable<HttpResult<List<GoodListBean>>> searchGoods(@Field("page") int page,
                                                           @Field("key") String key,
                                                           @Field("lat") String lat,
                                                           @Field("lng") String lng);

    /**
     * 二手需求搜索
     */
    @FormUrlEncoded
    @POST("sndmodule/Searchsndneeds")
    Observable<HttpResult<List<NeedBean>>> searchNeeds(@Field("page") int page,
                                                       @Field("key") String key,
                                                       @Field("lat") String lat,
                                                       @Field("lng") String lng);

    /**
     * 请求水果生鲜主页面分类模块及商品
     */
    @GET("fruit/Getfruitindex")
    Observable<HttpResult<List<FreshFruitHomeBean>>> getFreshHome();

    /**
     * 获取果蔬生鲜全部分类
     */
    @FormUrlEncoded
    @POST("fruit/Getfruitcat")
    Observable<HttpResult<List<FreshFruitCassifyBean>>> getFreshAllCassify(@Field("id") int id);

    /**
     * 发布果蔬商品
     */
    @FormUrlEncoded
    @POST("fruit/Addfruitgoods")
    Observable<HttpResult<List<GoodIdBean>>> putFreshGood(@Field("title") String title,
                                                          @Field("description") String descrption,
                                                          @Field("price") String price,
                                                          @Field("cat") int cat,
                                                          @Field("lat") String lat,
                                                          @Field("lng") String lng,
                                                          @Field("author") int author,
                                                          @Field("proarea") String proarea,
                                                          @Field("img") String img);

    /**
     * 查看果蔬商品详情
     */
    @FormUrlEncoded
    @POST("fruit/Getfruitgoods")
    Observable<HttpResult<List<GoodDetailBean>>> getFreshGoodDetail(@Field("id") int id);

    /**
     * 添加生鲜需求
     */
    @FormUrlEncoded
    @POST("fruit/Addfruitneeds")
    Observable<HttpResult<List<GoodIdBean>>> putFreshNeed(@Field("title") String title,
                                                          @Field("description") String description,
                                                          @Field("lat") String lat,
                                                          @Field("lng") String lng,
                                                          @Field("price") String price,
                                                          @Field("proarea") String proarea,
                                                          @Field("cat") int cat,
                                                          @Field("author") int author);


    /**
     * 获取需求详情
     */
    @FormUrlEncoded
    @POST("fruit/Getfruitneeds")
    Observable<HttpResult<List<NeedBean>>> getFreshNeedDetail(@Field("id") int id);

    /**
     * 果蔬获取商品列表
     */
    @FormUrlEncoded
    @POST("fruit/Getfruitcatgoods")
    Observable<HttpResult<List<GoodListBean>>> getFreshGoodList(@Field("id") int id,
                                                                @Field("page") int page,
                                                                @Field("lat") String lat,
                                                                @Field("lng") String lng,
                                                                @Field("issue") String issue,
                                                                @Field("price") String price,
                                                                @Field("dis") String dis);

    /**
     * 果蔬需求大厅列表及排序
     */
    @FormUrlEncoded
    @POST("fruit/Getfruitcatneeds")
    Observable<HttpResult<List<NeedBean>>> getFreshNeedList(@Field("id") int id,
                                                            @Field("page") int page,
                                                            @Field("lat") String lat,
                                                            @Field("lng") String lng,
                                                            @Field("issue") int issue);

    /**
     * 果蔬商品信息搜索
     */
    @FormUrlEncoded
    @POST("fruit/Searchfruitgoods")
    Observable<HttpResult<List<GoodListBean>>> searchFreshGoodList(@Field("page") int page,
                                                                   @Field("key") String key,
                                                                   @Field("lat") String lat,
                                                                   @Field("lng") String lng);

    /**
     * 果蔬需求搜索
     */
    @FormUrlEncoded
    @POST("fruit/Searchfruitneeds")
    Observable<HttpResult<List<NeedBean>>> searchFreshNeedList(@Field("page") int page,
                                                               @Field("key") String key,
                                                               @Field("lat") String lat,
                                                               @Field("lng") String lng);

    /**
     * 获取手机验证码
     *
     * @return
     */
    @FormUrlEncoded
    @POST("Alluser/Getcode")
    Observable<HttpResult<String>> getPhoneCode(@Field("phonenum") String phoneNum,
                                                @Field("state") int state);

    /**
     * 修改密码
     */
    @FormUrlEncoded
    @POST("Alluser/Userchangepsd")
    Observable<HttpResult<String>> updateUserPwd(@Field("phonenum") String phonenum,
                                                 @Field("state") int state,
                                                 @Field("password") String password,
                                                 @Field("code") int code,
                                                 @Field("id") int id);

    /**
     * 修改手机号
     */
    @FormUrlEncoded
    @POST("Alluser/Userchangephonenum")
    Observable<HttpResult<Object>> updatePhoneNum(@Field("phonenum") String phonenum,
                                                  @Field("state") int state,
                                                  @Field("code") int code,
                                                  @Field("id") int id);

    /**
     * 修改用户名
     */
    @FormUrlEncoded
    @POST("Alluser/Userchangepname")
    Observable<HttpResult<Object>> updateUserName(@Field("name") String name,
                                                  @Field("id") int id,
                                                  @Field("phonenum") String phoneNum);

    /**
     * 验证用户名是否存在 code:1 不存在 0 存在
     */
    @FormUrlEncoded
    @POST("Alluser/Checkusername")
    Observable<HttpResult<Object>> updateRepeatName(@Field("name") String name);

    /**
     * 找回密码
     */
    @FormUrlEncoded
    @POST("Alluser/Userlookpsd")
    Observable<HttpResult<Object>> findUserPwd(@Field("phonenum") String phonenum,
                                               @Field("state") int state,
                                               @Field("code") int code,
                                               @Field("password") String password);

}


